/**
 * @file:          Filter_FirstOrder.h
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2023.07.11
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.07.11,13:55:13
 */

#ifndef _FILTER_FIRSTORDER_H_
#define _FILTER_FIRSTORDER_H_

/* Include Files **************************************************************/
#include "Datatype.h"

/* Macro Definition ***********************************************************/

/* Data Type Define ***********************************************************/
typedef struct Filter_FirstOrder
{
    /* public data */
    uint16 param_en;
    float32 param_Ts;/* sample time: s */
    float32 param_fc;/* cut-off frequency: Hz */


    float32 Tc;/* time constant */
    float32 alpha;
    float32 y_last;
    float32 out_y;
    float32 in_x;

    /* private data */

    /* public method */
    void (*Init)(struct Filter_FirstOrder *self);
    float32 (*Run)(struct Filter_FirstOrder *self, float32 in);
    void (*Clear)(struct Filter_FirstOrder *self);
    void (*UpdateParam)(struct Filter_FirstOrder *self);

    /* private method */

} Filter_FirstOrder;
/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void Filter_FirstOrder_Init(struct Filter_FirstOrder *self);
float32 Filter_FirstOrder_Run(struct Filter_FirstOrder *self, float32 in);
void Filter_FirstOrder_Clear(struct Filter_FirstOrder *self);
void Filter_FirstOrder_UpdateParam(struct Filter_FirstOrder *self);

#endif